package com.zide.cms.controller;

import java.util.List;

import com.zide.cms.domain.vo.result.CmsBannerResultVO;
import com.zide.cms.domain.vo.save.CmsBannerSaveVO;
import com.zide.cms.domain.vo.search.CmsBannerSearchVO;
import com.zide.cms.service.ICmsBannerService;
import com.zide.common.core.vo.CommonParamIdVO;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zide.common.core.domain.PageResult;
import com.zide.common.core.domain.CommonResult;
import static com.zide.common.core.domain.CommonResult.getResult;
import static com.zide.common.core.domain.CommonResult.success;

/**
 * 轮播图管理Controller
 * 
 * @author zide
 * @date 2024-05-06
 */
@Tag(name = "轮播图管理")
@RestController
@RequestMapping("/cms/banner")
public class CmsBannerController {
    @Resource
    private ICmsBannerService cmsBannerService;

    @Operation(summary = "查询轮播图管理列表")
    @GetMapping("/list")
    public CommonResult list(CmsBannerSearchVO searchVO) {
        PageResult<CmsBannerResultVO> list = cmsBannerService.searchCmsBannerPageList(searchVO);
        return success(list);
    }

    @Operation(summary = "查询轮播图管理列表")
    @GetMapping("/page/{page}")
    public CommonResult searchPageBanner(@PathVariable("page") String page) {
        List<CmsBannerResultVO> list = cmsBannerService.searchPageBanner(page);
        return success(list);
    }

    @Operation(summary = "获取轮播图管理详细信息")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id) {
        return success(cmsBannerService.selectCmsBannerById(id));
    }

    @Operation(summary = "新增轮播图管理")
    @PostMapping
    public CommonResult add(@RequestBody CmsBannerSaveVO saveVO) {
        return getResult(cmsBannerService.saveCmsBanner(saveVO));
    }

    @Operation(summary = "修改轮播图管理")
    @PutMapping
    public CommonResult edit(@RequestBody CmsBannerSaveVO saveVO){
        return getResult(cmsBannerService.updateCmsBanner(saveVO));
    }

    @Operation(summary = "删除轮播图管理")
	@DeleteMapping
    public CommonResult remove(@RequestBody CommonParamIdVO idVO){
        return getResult(cmsBannerService.removeCmsBannerByIds(idVO));
    }
}
